import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		token: null,
		userInfo: {},
		hasLogin: false
	},
	mutations: {
		login(state, userInfo) {
			state.userInfo = userInfo
			state.hasLogin = true
		},
		logout(state) {
			state.userInfo = {}
			state.hasLogin = false
		},
		saveToken(state, token) {
			state.token = token
		}
	}
})

export default store
